<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="9" :md="10" :sm="24">
            <a-form-item label="班级">
              <j-select-banji  v-model="queryParam.bjid" placeholder="请选择班级"></j-select-banji>
<!--              <j-dict-select-tag-->
<!--                v-model="queryParam.bjid"-->
<!--                placeholder="请选择班级"-->
<!--                dictCode="edu_dev.ve_jw_bjgg,name,id"-->
<!--              ></j-dict-select-tag>-->
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="11" :md="12" :sm="24">
            <a-form-item label="发布时间">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.addtime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.addtime_end"></j-date>
            </a-form-item>
          </a-col>

<!--          <a-col :xl="4" :lg="7" :md="8" :sm="24">-->
<!--            <a-form-item label="审核状态">-->
<!--              <j-dict-select-tag-->
<!--                v-model="queryParam.verifystatus"-->
<!--                placeholder="请选择"-->
<!--                dictCode="verifystatus"-->
<!--              ></j-dict-select-tag>-->
<!--            </a-form-item>-->
<!--          </a-col>-->

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
             <edu-button type="5" @click="searchQuery" icon="search" title="搜索"
                         style="margin-bottom: 0"></edu-button><edu-button type="7" @click="searchReset"
                                                                           icon="delete" title="清除"
                                                                           style="margin-bottom: 0"></edu-button>
<!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />-->
<!--              </a>-->
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator" :md="24" :sm="24" style="margin: 0px 0px 10px 2px">
      <edu-button @click="handleAdd" type="3" icon="plus" title="添加"/>
      <edu-button type="1" @click="searchQuery" icon="sync" title="刷新"></edu-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDelConfirm">
            <edu-batch-delete-button ref="batchDelBtn" @del="batchDelAction"  type="4" title="删除"></edu-batch-delete-button>
          </a-menu-item>
        </a-menu>
        <edu-button type="10" title="批量操作" icon="down" style="margin-bottom: 0px" rightIcon="true">
        </edu-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        @change="handleTableChange"
      >
        <span slot="action" slot-scope="text, record">
          <edu-label-button type="1" @click="checkBjgg(record)" title="查看"></edu-label-button>
          <a-divider type="vertical"  v-if="record.verifyuser == null || record.verifyuser == '' ||record.verifystatus == '0'"/>
          <edu-label-button type="3" title="修改" @click="updateEdit(record)" v-if="record.verifyuser == null || record.verifyuser == '' ||record.verifystatus == '0'"></edu-label-button>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <VeJwBjggModal ref="modalForm" @ok="modalFormOk"></VeJwBjggModal>
    <VeJwBjggCheckModal ref="checkModalForm" @ok="modalFormOK"></VeJwBjggCheckModal>
  </a-card>
</template>

<script>
import { EduListMixin } from '@/mixins/EduListMixin'
import { getAction } from '@/api/manage'
import VeJwBjggModal from './modules/VeJwBjggModal'
import VeJwBjggCheckModal from './modules/VeJwBjggCheckModal'
import { formatDate } from '@/utils/util'
import JSelectBanji from '../../components/kwglbiz/JSelectBanji'

export default {
  name: 'EduOrderTicketList',
  mixins: [EduListMixin],
  components: {
    JSelectBanji,
    VeJwBjggModal,
    VeJwBjggCheckModal,
  },
  data() {
    return {
      description: 've_jw_bjgg管理页面',
      // 表头
      columns: [
        {
          title: '班级名称',
          align: 'center',
          dataIndex: 'bjmc',
        },
        {
          title: '标题',
          align: 'center',
          dataIndex: 'title',
        },
        {
          title: '日期',
          align: 'center',
          dataIndex: 'addtime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '教师名称',
          align: 'center',
          dataIndex: 'addusername',
        },
        {
          title: '评审状态',
          align: 'center',
          dataIndex: 'verifystatus_dictText',
        },
        // {
        //   title:'审核人',
        //   align:"center",
        //   dataIndex: 'verifyuser'
        // },
        {
          title: '评审人',
          align: 'center',
          dataIndex: 'verifyusername',
        },
        {
          title: '评审时间',
          align: 'center',
          dataIndex: 'verifytime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/jxgz/veJwBjgg/list',
        delete: '/jxgz/veJwBjgg/delete',
        deleteBatch: '/jxgz/veJwBjgg/deleteBatch',
        exportXlsUrl: '/jxgz/veJwBjgg/exportXls',
        importExcelUrl: 'jxgz/veJwBjgg/importExcel',
      },
      dictOptions: {},
      isorter: {
        column: 'id',
        order: 'desc',
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  created(){
    if(!this.disableMixinCreated){
      console.log(' -- mixin created -- ')
      this.loadData();
      //初始化字典配置 在自己页面定义
      this.initDictConfig();
    }
  },
  methods: {
    loadData(arg) {
      if(!this.url.list){
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      this.queryParam.adduser = window.localStorage.getItem('userId');
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records||res.result;
          if(res.result.total)
          {
            this.ipagination.total = res.result.total;
          }
          //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        }
        if(res.code===510){
          this.$message.warning(res.message)
        }
        this.loading = false;
      })
    },
    initDictConfig() {},
    //我的班级公告-查看我的班级公告
    checkBjgg: function (record) {
      this.$refs.checkModalForm.edit(record)
      this.$refs.checkModalForm.title = '查看我的班级公告'
      this.$refs.checkModalForm.disableSubmit = false
    },

    //我的班级公告-修改我的班级公告
    updateEdit: function (record) {
      this.$refs.modalForm.edit(record)
      this.$refs.modalForm.title = '编辑我的班级公告'
      this.$refs.modalForm.disableSubmit = false
    },

    handleAdd: function () {
      this.$refs.modalForm.add()
      this.$refs.modalForm.title = '新增班级公告'
      this.$refs.modalForm.disableSubmit = false
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/usercolor.less';
</style>